package com.collectplus.express.self;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.collectplus.express.R;
import com.collectplus.express.model.CouponBean;

import java.util.ArrayList;

import droid.frame.activity.base.BaseAdapterWithImage;

/**
 * Created by joker on 2017/8/28.
 * 支付界面选择邮票适配器
 */
public class SelfOrderPayStampAdapter extends BaseAdapterWithImage<CouponBean> {

    public SelfOrderPayStampAdapter(ArrayList<CouponBean> items, Activity context, ViewGroup listView) {
        super(items, context, listView);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(R.layout.self_orderpay_stamp_item, parent, false);
            holder = new ViewHolder();
            holder.stampIV = (ImageView) convertView.findViewById(R.id.stamp_iv);
            holder.stampNameTV = (TextView) convertView.findViewById(R.id.stamp_name_tv);
            holder.stampResidueNumTV = (TextView) convertView.findViewById(R.id.stamp_residue_num_tv);
            holder.stampPeriodValidityTV = (TextView) convertView.findViewById(R.id.stamp_period_validity_tv);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        CouponBean item = getItem(position);
        showImage(item.getStampImage(), holder.stampIV, null);
        holder.stampNameTV.setText(item.getStampName());
        holder.stampResidueNumTV.setText("当前剩余" + item.getStampNum() + "张");
        holder.stampPeriodValidityTV.setText(item.getExpireRemain() + "后过期");
        return convertView;
    }

    private class ViewHolder {
        ImageView stampIV;//邮票图片
        TextView stampNameTV;// 邮票名称
        TextView stampResidueNumTV;// 邮票剩余数量
        TextView stampPeriodValidityTV;// 邮票剩余使用天数
    }
}
